import { createRouter, createWebHashHistory } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';
import { menuStore } from '../store/menuStore';


const routes: RouteRecordRaw[] = [
    {
        path: '/',
        redirect: '/Layout'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('/src/view/login/index.vue')
    },
    {
        path: '/Layout',
        name: 'Layout',
        component: () => import('/src/view/Layout/index.vue'),
        children: [
            // {
            //     path: 'HomePage',
            //     name: 'HomePage',
            //     component: () => import('/src/view/Layout/HomePage/index.vue'),
            // }
        ]
    },
    {
        path: '/:pathMatch(.*)*',
        component: () => import('@/view/not-found/index.vue')
    } 
];

const router = createRouter({
    routes,
    history: createWebHashHistory()
});

router.beforeEach((from,to,next) => {
    console.log(from, to);
    //重定向到mainPage页面
    if (!to.path) {
        
        // const store = menuStore();
        // store.mapMenus();
        // next(to.fullPath)
    }
    next()
})

export default router;